﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NumberTest.Question;

namespace NumberTest.Answer
{
    class Jimson:iNumberTest
    {
        public int CountTest(long start, long end)
        {
            int[] count = new int[10];

            for (long i = start; i < end; i++)
            {
                GetCount(i, count);
            }


            return Found(count);

        }

        void GetCount(long Num, int[] arr)
        {           
            while (Num > 0)
            {
                arr[Num % 10]++;
                Num = Num / 10;
            }
        }

        int Found(int[] arr)
        {
            
            int i = 0;
            for ( i = 0; i < arr.Length; i++)
            {
                if (arr[i] == arr.Max())
                    break;
               
            }
            return i;
        }
    }
}
